package com.dhee.creditcardsystem.dao.Impl;

import com.dhee.creditcardsystem.dao.UsersDao;
import com.dhee.creditcardsystem.model.Users;
import com.dhee.creditcardsystem.util.DBUtilUserC;
import com.dhee.creditcardsystem.util.DBUtilZSG;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;

@Repository
public class UsersDaoImpl implements UsersDao {


    @Override
    public Users selectByLoginn(String loginn) {

        String sql = "select * from usr where loginn = ?";
        try {

           return DBUtilUserC.dml(sql, loginn);
        } catch (SQLException e) {

        }
        return null;
    }

    @Override
    public int addUsers(Users users) {
//        String sql = "insert into usr values(?,?,?,?,?,?,?,?,?,?,?,?,?)";

        // UsersDaoImpl.addUsers 方法中
        String sql = "INSERT INTO usr (loginn, disn, pass, ser, token, kbn, mail, insertdte, insertid, updatedte, updateid, deleteflg, deletedte) " +
                "VALUES (?, ?, ?, ?, ?, ?, ?, TO_DATE(?, 'YYYYMMDDHH24MISS'), ?, TO_DATE(?, 'YYYYMMDDHH24MISS'), ?, ?, TO_DATE(?, 'YYYYMMDDHH24MISS'))";

        try {
            return DBUtilZSG.dml(sql, users.getLoginn(), users.getDisn(), users.getPass(), users.getSer(), users.getToken(), users.getKbn(), users.getMail(), users.getInsertdte(), users.getInsertid(), users.getUpdatedte(), users.getUpdateid(), users.getDeleteflg(), users.getDeletedte());


        }
        catch (SQLException e) {

            e.printStackTrace();
        }


        return 0;
    }
}
